use crate::direction::Dir;
use derive_more::{
    Add, AddAssign, Constructor, Display, From, Into, Mul, MulAssign, Sub, SubAssign,
};

#[derive(
    Clone,
    Copy,
    PartialEq,
    Eq,
    Hash,
    Default,
    Debug,
    Add,
    Sub,
    Mul,
    AddAssign,
    SubAssign,
    MulAssign,
    Display,
    Constructor,
    Into,
    From,
)]
#[display(fmt = "({x}, {y})")]
pub struct Coord {
    pub x: i32,
    pub y: i32,
}

impl From<Dir> for Coord {
    fn from(value: Dir) -> Self {
        match value {
            Dir::Down => (0, 1),
            Dir::Up => (0, -1),
            Dir::Right => (1, 0),
            Dir::Left => (-1, 0),
        }
        .into()
    }
}
